home *** CD-ROM | disk | FTP | other *** search
-
- #pragma segment MISC
-
- /*
- ** This source code was written by Tim Endres
- ** Email: time@ice.com.
- ** USMail: 8840 Main Street, Whitmore Lake, MI 48189
- **
- ** Some portions of this application utilize sources
- ** that are copyrighted by ICE Engineering, Inc., and
- ** ICE Engineering retains all rights to those sources.
- **
- ** Neither ICE Engineering, Inc., nor Tim Endres,
- ** warrants this source code for any reason, and neither
- ** party assumes any responsbility for the use of these
- ** sources, libraries, or applications. The user of these
- ** sources and binaries assumes all responsbilities for
- ** any resulting consequences.
- */
-
- #include "tickle.h"
- #include <fcntl.h>
- #include <string.h>
- #include <traps.h>
- #include "tge.h"
- #include "tclMac.h"
-
-
- #pragma segment Init
-
- InitApplication()
- {
- int i;
- char volname[32];
- Handle SystemResource();
-
- /*
- ** FIRST THING!!!!
- ** Before any lame procedures start changing the directory...
- */
- TclMac_CWDInitialize();
-
- /* Initialize globals before calling other
- ** initialization routines, as they may need
- ** these globals to be initialized.
- */
- verbose = true;
- quiet = false;
-
- /* Get application's open resource fork reference number. */
- app_refnum = CurResFile();
- /* Get working directory/volume reference number of application. */
- GetVol(volname, &app_vrefnum);
- g_log_wdref = app_vrefnum;
-
- if ( GetRefnumFileName(app_filename, app_refnum) != noErr )
- {
- strcpy(app_filename, "Tickle");
- c2pstr(app_filename);
- }
-
- #ifdef TCL_APPL
- SFWDDefault(app_vrefnum);
- SFSaveDefault();
- #endif
-
- /* Set up some Macintosh variables for the desktop stuff. */
- dragrect = scrnrect = qd.screenBits.bounds;
- dragrect.top += 20; /* Adjust for menu bar (20 pels) */
- InsetRect(&dragrect, 4, 4); /* Limit to ON screen */
-
- has_wait_next_event = WNEAvailable();
-
- #ifdef TCLENGINE
- SetVol(NULL, app_vrefnum);
- logfile = fopen("ENGINE LOG", "a");
- if (logfile == NULL)
- {
- extern int errno;
-
- message_alert("Error #%d opening log file.", errno);
- }
- #endif
-
- #ifdef TCLAPPL
- /* Initialize our focus-ing routines. */
- InitFocus();
-
- /* Set up the Macintosh menus for DiskTool. */
- create_menus();
-
- /*
- ** WARNING: Be sure to do this AFTER setting up scrnrect, which CenterAll()'s
- ** algorithm requires.
- */
- CenterAll((ResType)'DLOG', 1);
- CenterAll((ResType)'ALRT', 1);
- PrintInit();
- #endif
-
- notify_icons[NOTIFY_COPY_COMPLETE]
- = SystemResource((ResType)'SICN', NOTIFY_ID(NOTIFY_COPY_COMPLETE));
- notify_icons[NOTIFY_BINHEX]
- = SystemResource((ResType)'SICN', NOTIFY_ID(NOTIFY_BINHEX));
- notify_icons[NOTIFY_SIT]
- = SystemResource((ResType)'SICN', NOTIFY_ID(NOTIFY_SIT));
- notify_icons[NOTIFY_ZED]
- = SystemResource((ResType)'SICN', NOTIFY_ID(NOTIFY_ZED));
- notify_icons[NOTIFY_UU]
- = SystemResource((ResType)'SICN', NOTIFY_ID(NOTIFY_UU));
- notify_icons[NOTIFY_NEED_DISK]
- = SystemResource((ResType)'SICN', NOTIFY_ID(NOTIFY_NEED_DISK));
- for (i=0; i < NUM_OF_NOTIFY_ICONS; i++)
- HNoPurge(notify_icons[i]);
-
- tge_sicns = GetResource((ResType)'SICN', (short)8888);
- if (tge_sicns != NULL) {
- LoadResource(tge_sicns);
- DetachResource(tge_sicns);
- MoveHHi(tge_sicns);
- HNoPurge(tge_sicns);
- }
-
- #ifdef TCLAPPL
- InitFeedbackWindow();
- ShowFeedback();
- #endif
-
- if (gHasAppleEvents)
- InitAEStuff();
-
- #ifdef TCLENGINE
- Feedback("tclEngine - Derived from uAccess and other USENET efforts.");
- #else
- Feedback("tickle - Derived from uAccess and other USENET efforts.");
- #endif
-
- TclMac_InitializeOnce(app_refnum);
-
- TclTickle_InitializeOnce(app_vrefnum);
-
- UInitCursor();
- }
-
- ShutDownApplication()
- {
- #ifdef TCLAPPL
- WindowPeek myWindow, lastW = NULL;
-
- /*
- ** Walk through the linked list of visible windows
- ** and send the "close" message to each of OUR windows.
- */
- myWindow = (WindowPeek) FrontWindow();
- while (myWindow != NULL && app_done) {
- if (myWindow == lastW)
- {
- CloseWindow((WindowPtr) myWindow);
- myWindow = (WindowPeek) FrontWindow();
- lastW = (WindowPeek) 0;
- continue;
- }
-
- if (checkmywindow(myWindow))
- wind_parse(myWindow, NULL, wClose);
-
- lastW = myWindow;
- myWindow = (WindowPeek) FrontWindow();
- }
- #endif
-
- if (! app_done)
- return;
-
- TclTickle_ShutDown();
-
- clear_notify_q(NOTIFY_ALL);
-
- if (xtcl_refnum != -1)
- CloseResFile(xtcl_refnum);
-
- if (logfile != NULL)
- fclose(logfile);
- }
-
- CenterAll(type, high_flag)
- ResType type;
- int high_flag; /* If true, then bump em up a little. */
- {
- short saveref; /* ref num of our resource file */
- short number; /* number of resources of type rezType */
- short i; /* index into resource list */
- Handle rsrc; /* handle to resource */
-
- saveref = CurResFile();
- UseResFile(app_refnum);
-
- number = Count1Resources(type);
- for (i = 1; i <= number; i++) {
- rsrc = Get1IndResource(type, i);
- if (rsrc != NULL)
- if (high_flag)
- HighCenterRect(*( (Rect **) rsrc ));
- else
- CenterRect(*( (Rect **) rsrc ));
- }
-
- UseResFile(saveref);
- }
-